import { axios } from '@/utils/request'

const api = {
  list: '/wms/finished-goods-inbound/list',
  create: '/wms/finished-goods-inbound/create',
  update: '/wms/finished-goods-inbound/update',
  createByOrder: '/wms/finished-goods-inbound/createByOrder',
  execute: '/wms/finished-goods-inbound/execute',
  detail: '/wms/finished-goods-inbound/detail',
  delete: '/wms/finished-goods-inbound/delete',
  deleteBatch: '/wms/finished-goods-inbound/deleteBatch',
  availableOrders: '/oms/order/available-for-inbound'
}

/**
 * 查询成品入库单列表
 */
export function getFinishedGoodsInboundList(parameter) {
  return axios({
    url: api.list,
    method: 'get',
    params: parameter
  })
}

/**
 * 创建成品入库单
 */
export function createInbound(parameter) {
  return axios({
    url: api.create,
    method: 'post',
    data: parameter
  })
}

/**
 * 根据订单编号创建成品入库单
 */
export function createInboundByOrder(parameter) {
  return axios({
    url: api.createByOrder,
    method: 'post',
    data: parameter
  })
}

/**
 * 执行成品入库
 */
export function executeInbound(id) {
  return axios({
    url: `${api.execute}/${id}`,
    method: 'post'
  })
}

/**
 * 更新成品入库单
 */
export function updateInbound(parameter) {
  return axios({
    url: api.update,
    method: 'put',
    data: parameter
  })
}

/**
 * 查询入库单详情
 */
export function getInboundDetail(id) {
  return axios({
    url: `${api.detail}/${id}`,
    method: 'get'
  })
}

/**
 * 删除成品入库单
 */
export function deleteFinishedGoodsInbound(parameter) {
  return axios({
    url: api.delete,
    method: 'delete',
    params: parameter
  })
}

/**
 * 批量删除成品入库单
 */
export function batchDeleteFinishedGoodsInbound(parameter) {
  return axios({
    url: api.deleteBatch,
    method: 'delete',
    params: parameter
  })
}

/**
 * 获取可入库的订单列表
 */
export function getAvailableOrdersForInbound(parameter) {
  return axios({
    url: api.availableOrders,
    method: 'get',
    params: parameter
  })
}
